package com.tjetc.Impl;

import com.tjetc.domain.Health;
import com.tjetc.mapper.HealthMapper;
import com.tjetc.service.HealthService;
import com.tjetc.utils.Db;
import com.tjetc.vo.Result;

public class HealthServiceImpl implements HealthService {
    HealthMapper healthMapper = Db.getMapper(HealthMapper.class);
    Result result=new Result();

    public Result addHealth(Health health)
    {
        int i = healthMapper.insertSelective(health);
        if(i>0)
        {
            result.setCode(200);
            result.setMsg("添加成功");
            return  result;
        }
        else
        {
            result.setCode(500);
            result.setMsg("添加失败");
            return  result;
        }
    }
    public Result updateHealth(Health health)
    {
        int i = healthMapper.updateHealth(health);
        if(i>0)
        {
            result.setCode(200);
            result.setMsg("修改成功");
            return result;
        }
        else
        {
            result.setCode(500);
            result.setMsg("修改失败");
            return result;
        }

    }

    @Override
    public Health findHealth(int id) {
        return null;
    }

    public Result deleteHealth(int id)
    {
        int i = healthMapper.deleteHealth(id);
        if(i>0)
        {
            result.setCode(200);
            result.setMsg("删除成功");
            return result;
        }
        else
        {
            result.setCode(500);
            result.setMsg("删除失败");
            return result;
        }
    }

    @Override
    public int findNumberOfDisease(int id) {
        return 0;
    }

    @Override
    public Result add(Health health) {
        return null;
    }

    public Health getHealthById(int id)
    {
        return healthMapper.findHealth(id);
    }

}
